<template>
  <div class="content">
    <div class="handles">
      <Button type="primary" @click="exportData">导出Excel</Button>
    </div>
    <dt-grid ref="table" :columns="columns" :page='page' :onFetch='onFetch' />
  </div>
</template>
<script>
  import columnOpt from './opt/buyRecordColumn'
  import receiverMgr from '@/biz/receiver/receiver'
  export default {
    components: {},
    data() {
      return {
        userId: this.$route.query.userId,
        columns: [],
        page: {
          current: 1,
          total: 0
        },
      }
    },
    mounted() {
      this.$refs.table.init(this, new columnOpt(this))
      this.$refs.table.fetch()
    },
    methods: {
      exportData() {
        receiverMgr.exportPrivacyNumberPackageList(this.getListParams)
      },
      onFetch(data) {
        this.getListParams = data
        if (!this.getListParams.userId) {
          if (this.userId) {
            this.getListParams.userId = this.userId
          }
        }
        return receiverMgr.getPrivacyNumberPackageList(this.getListParams).then(res => {
          this.page.total = res.total
          return res.list
        })
      }
    },
  }
</script>

<style lang="scss" scoped>
  .content {
    padding: 20px;
  }
</style>